package com.vueperson.vueperson.services.User;

import com.vueperson.vueperson.dao.UserJPA;
import com.vueperson.vueperson.entity.User;
import com.vueperson.vueperson.services.UserTools;
import com.vueperson.vueperson.services.handle.Role01_2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import java.util.List;

public class UserService implements UserDetailsService {
    @Autowired
    User user;
    @Autowired
    UserTools userTools;
    @Autowired
    UserJPA userJPA;
    @Autowired
    Role01_2 userIf;
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        if (!userIf.haveUser(username)){
            throw new UsernameNotFoundException("账户不存在");
        }else {
            List<User> userList=userJPA.findByUsername(username);
            user=userList.get(0);
//            user.setRole();
        }

        return null;
    }
}
